#!/usr/bin/env python
# encoding: utf-8
'''
@author: wangjianrong
@software: pycharm
@file: random_metric.py
@time: 2020/10/16 14:18
@desc:
'''

import random

target_acc = [0.90,0.98]

#正样本数量范围
range_pos = [800,1200]
#负样本/正样本比例
range_ratio = [0.8,1.2]
#误报数量范围
err_neg = [0,50]
#漏报数量占所有正样本比例范围
lose_ratio = [0.05,0.15]
#场景数
total_num = 20

for i in range(total_num):
    num_pos = random.randint(range_pos[0],range_pos[1])
    ratio = random.uniform(range_ratio[0],range_ratio[1])
    num_neg = int(ratio*num_pos)
    while True:
        #误报
        num_err = random.randint(err_neg[0],err_neg[1])
        #漏报
        ratio_lose = random.uniform(lose_ratio[0],lose_ratio[1])
        num_lose = int(num_pos*ratio_lose)
        #正确数
        num_right = num_pos - num_lose + num_neg - num_err
        #准确率
        acc = num_right / (num_pos + num_neg)
        if acc >= target_acc[0] and acc<= target_acc[1]:
            print("{} {} {} {} {} {:.2f}%".format(num_pos,num_neg,num_right,num_err,num_lose,acc*100))
            break

